
package gallery.album.asset
{

    import flash.text.TextField;
    import flash.text.TextFormat;
    
    import gallery.asset.*;
    
    import mx.controls.Image;
    import mx.core.UIComponent;


    public class AlbumPhoto extends UIComponent
    {
        private var image:LoadingImage;
        private var label:TextField;

        public function AlbumPhoto()
        {
            super();
            image = new LoadingImage();
            label = new TextField();
        }

        override protected function createChildren():void
        {
            super.createChildren();
            image.setStyle("verticalAlign", "middle");
            image.setStyle("horizontalAlign", "center");
            
            //format the alignment of label
            var format:TextFormat = new TextFormat();
            format.align = "center";
            format.font = "Georgia";
            format.size = 12;
            label.setTextFormat(format);
            addChild(image);
            addChild(label);
            
            
            
            
            //set the x and y and width of components
            label.x = image.x;
            label.y = image.y + image.height + 5;
            label.height = 17;
            label.width = image.width;
        }
        
        public function get text(): String {
        	return label.text as String;
        }
        
        public function set text(value:String): void {
        	label.text = value;
        }
        

        public function get source():String
        {
            return image.source as String;
        }

        public function set source(value:String):void
        {
            image.source = value;
        }

        override public function set width(value:Number):void
        {
            super.width = value;
            image.width = value;
        }

        override public function get width():Number
        {
            return super.width;
        }

        override public function set height(value:Number):void
        {
            super.height = value;
            image.height = value;
        }

        override public function get height():Number
        {
            return super.height;
        }

        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            
        }

    }
}